﻿using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria.GameContent.Biomes;
using Terraria.ID;
using Terraria.ObjectData;

namespace Terraria.ModLoader
{
	// Token: 0x02000246 RID: 582
	public static class TileLoader
	{
		// Token: 0x0600186F RID: 6255 RVA: 0x0041E67C File Offset: 0x0041C87C
		internal static int ReserveTileID()
		{
			if (ModNet.AllowVanillaClients)
			{
				throw new Exception("Adding tiles breaks vanilla client compatiblity");
			}
			int result = TileLoader.nextTile;
			TileLoader.nextTile++;
			return result;
		}

		// Token: 0x170001B8 RID: 440
		// (get) Token: 0x06001870 RID: 6256 RVA: 0x00011FD6 File Offset: 0x000101D6
		public static int TileCount
		{
			get
			{
				return TileLoader.nextTile;
			}
		}

		// Token: 0x06001871 RID: 6257 RVA: 0x00011FDD File Offset: 0x000101DD
		public static ModTile GetTile(int type)
		{
			if (type < 470 || type >= TileLoader.TileCount)
			{
				return null;
			}
			return TileLoader.tiles[type - 470];
		}

		// Token: 0x06001872 RID: 6258 RVA: 0x0041E6B0 File Offset: 0x0041C8B0
		private static void Resize2DArray<T>(ref T[,] array, int newSize)
		{
			int length = array.GetLength(0);
			int length2 = array.GetLength(1);
			T[,] array2 = new T[newSize, length2];
			int num = 0;
			while (num < newSize && num < length)
			{
				for (int i = 0; i < length2; i++)
				{
					array2[num, i] = array[num, i];
				}
				num++;
			}
			array = array2;
		}

		// Token: 0x06001873 RID: 6259 RVA: 0x0041E710 File Offset: 0x0041C910
		internal unsafe static void ResizeArrays(bool unloading = false)
		{
			Array.Resize<bool>(ref Main.tileSetsLoaded, TileLoader.nextTile);
			for (int i = 470; i < TileLoader.nextTile; i++)
			{
				Main.tileSetsLoaded[i] = true;
			}
			Array.Resize<Texture2D>(ref Main.highlightMaskTexture, TileLoader.nextTile);
			TileLoader.Resize2DArray<RenderTarget2D>(ref Main.tileAltTexture, TileLoader.nextTile);
			TileLoader.Resize2DArray<bool>(ref Main.tileAltTextureInit, TileLoader.nextTile);
			TileLoader.Resize2DArray<bool>(ref Main.tileAltTextureDrawn, TileLoader.nextTile);
			Array.Resize<Texture2D>(ref Main.tileTexture, TileLoader.nextTile);
			Array.Resize<bool>(ref Main.tileLighted, TileLoader.nextTile);
			Array.Resize<bool>(ref Main.tileMergeDirt, TileLoader.nextTile);
			Array.Resize<bool>(ref Main.tileCut, TileLoader.nextTile);
			Array.Resize<bool>(ref Main.tileAlch, TileLoader.nextTile);
			Array.Resize<int>(ref Main.tileShine, TileLoader.nextTile);
			Array.Resize<bool>(ref Main.tileShine2, TileLoader.nextTile);
			Array.Resize<bool>(ref Main.tileStone, TileLoader.nextTile);
			Array.Resize<bool>(ref Main.tileAxe, TileLoader.nextTile);
			Array.Resize<bool>(ref Main.tileHammer, TileLoader.nextTile);
			Array.Resize<bool>(ref Main.tileWaterDeath, TileLoader.nextTile);
			Array.Resize<bool>(ref Main.tileLavaDeath, TileLoader.nextTile);
			Array.Resize<bool>(ref Main.tileTable, TileLoader.nextTile);
			Array.Resize<bool>(ref Main.tileBlockLight, TileLoader.nextTile);
			Array.Resize<bool>(ref Main.tileNoSunLight, TileLoader.nextTile);
			Array.Resize<bool>(ref Main.tileDungeon, TileLoader.nextTile);
			Array.Resize<bool>(ref Main.tileSpelunker, TileLoader.nextTile);
			Array.Resize<bool>(ref Main.tileSolidTop, TileLoader.nextTile);
			Array.Resize<bool>(ref Main.tileSolid, TileLoader.nextTile);
			Array.Resize<bool>(ref Main.tileBouncy, TileLoader.nextTile);
			Array.Resize<short>(ref Main.tileValue, TileLoader.nextTile);
			Array.Resize<byte>(ref Main.tileLargeFrames, TileLoader.nextTile);
			Array.Resize<bool>(ref Main.tileRope, TileLoader.nextTile);
			Array.Resize<bool>(ref Main.tileBrick, TileLoader.nextTile);
			Array.Resize<bool>(ref Main.tileMoss, TileLoader.nextTile);
			Array.Resize<bool>(ref Main.tileNoAttach, TileLoader.nextTile);
			Array.Resize<bool>(ref Main.tileNoFail, TileLoader.nextTile);
			Array.Resize<bool>(ref Main.tileObsidianKill, TileLoader.nextTile);
			Array.Resize<bool>(ref Main.tileFrameImportant, TileLoader.nextTile);
			Array.Resize<bool>(ref Main.tilePile, TileLoader.nextTile);
			Array.Resize<bool>(ref Main.tileBlendAll, TileLoader.nextTile);
			Array.Resize<short>(ref Main.tileGlowMask, TileLoader.nextTile);
			Array.Resize<bool>(ref Main.tileContainer, TileLoader.nextTile);
			Array.Resize<bool>(ref Main.tileSign, TileLoader.nextTile);
			Array.Resize<bool[]>(ref Main.tileMerge, TileLoader.nextTile);
			for (int j = 0; j < TileLoader.nextTile; j++)
			{
				Array.Resize<bool>(ref Main.tileMerge[j], TileLoader.nextTile);
			}
			Array.Resize<bool>(ref Main.tileSand, TileLoader.nextTile);
			Array.Resize<bool>(ref Main.tileFlame, TileLoader.nextTile);
			Array.Resize<int>(ref Main.tileFrame, TileLoader.nextTile);
			Array.Resize<int>(ref Main.tileFrameCounter, TileLoader.nextTile);
			Array.Resize<int>(ref Main.screenTileCounts, TileLoader.nextTile);
			Array.Resize<int>(ref WorldGen.tileCounts, TileLoader.nextTile);
			Array.Resize<bool>(ref WorldGen.houseTile, TileLoader.nextTile);
			Array.Resize<bool>(ref CaveHouseBiome._blacklistedTiles, TileLoader.nextTile);
			Array.Resize<bool>(ref CorruptionPitBiome.ValidTiles, TileLoader.nextTile);
			Array.Resize<bool>(ref TileID.Sets.Conversion.Grass, TileLoader.nextTile);
			Array.Resize<bool>(ref TileID.Sets.Conversion.Stone, TileLoader.nextTile);
			Array.Resize<bool>(ref TileID.Sets.Conversion.Ice, TileLoader.nextTile);
			Array.Resize<bool>(ref TileID.Sets.Conversion.Sand, TileLoader.nextTile);
			Array.Resize<bool>(ref TileID.Sets.Conversion.HardenedSand, TileLoader.nextTile);
			Array.Resize<bool>(ref TileID.Sets.Conversion.Sandstone, TileLoader.nextTile);
			Array.Resize<bool>(ref TileID.Sets.Conversion.Thorn, TileLoader.nextTile);
			Array.Resize<bool>(ref TileID.Sets.Conversion.Moss, TileLoader.nextTile);
			Array.Resize<bool>(ref TileID.Sets.ForAdvancedCollision.ForSandshark, TileLoader.nextTile);
			Array.Resize<bool>(ref TileID.Sets.Platforms, TileLoader.nextTile);
			Array.Resize<bool>(ref TileID.Sets.DrawsWalls, TileLoader.nextTile);
			Array.Resize<ushort>(ref TileID.Sets.GemsparkFramingTypes, TileLoader.nextTile);
			Array.Resize<bool>(ref TileID.Sets.TeamTiles, TileLoader.nextTile);
			Array.Resize<int>(ref TileID.Sets.ConveyorDirection, TileLoader.nextTile);
			Array.Resize<bool>(ref TileID.Sets.HasSlopeFrames, TileLoader.nextTile);
			Array.Resize<bool>(ref TileID.Sets.TileInteractRead, TileLoader.nextTile);
			Array.Resize<bool>(ref TileID.Sets.HasOutlines, TileLoader.nextTile);
			Array.Resize<bool>(ref TileID.Sets.AllTiles, TileLoader.nextTile);
			Array.Resize<bool>(ref TileID.Sets.Stone, TileLoader.nextTile);
			Array.Resize<bool>(ref TileID.Sets.Grass, TileLoader.nextTile);
			Array.Resize<bool>(ref TileID.Sets.Mud, TileLoader.nextTile);
			Array.Resize<bool>(ref TileID.Sets.Snow, TileLoader.nextTile);
			Array.Resize<bool>(ref TileID.Sets.Ices, TileLoader.nextTile);
			Array.Resize<bool>(ref TileID.Sets.IcesSlush, TileLoader.nextTile);
			Array.Resize<bool>(ref TileID.Sets.IcesSnow, TileLoader.nextTile);
			Array.Resize<bool>(ref TileID.Sets.GrassSpecial, TileLoader.nextTile);
			Array.Resize<bool>(ref TileID.Sets.JungleSpecial, TileLoader.nextTile);
			Array.Resize<bool>(ref TileID.Sets.HellSpecial, TileLoader.nextTile);
			Array.Resize<bool>(ref TileID.Sets.Leaves, TileLoader.nextTile);
			Array.Resize<bool>(ref TileID.Sets.GeneralPlacementTiles, TileLoader.nextTile);
			Array.Resize<bool>(ref TileID.Sets.BasicChest, TileLoader.nextTile);
			Array.Resize<bool>(ref TileID.Sets.BasicChestFake, TileLoader.nextTile);
			Array.Resize<bool>(ref TileID.Sets.CanBeClearedDuringGeneration, TileLoader.nextTile);
			Array.Resize<bool>(ref TileID.Sets.CanBeClearedDuringOreRunner, TileLoader.nextTile);
			Array.Resize<bool>(ref TileID.Sets.Corrupt, TileLoader.nextTile);
			Array.Resize<bool>(ref TileID.Sets.Hallow, TileLoader.nextTile);
			Array.Resize<bool>(ref TileID.Sets.Crimson, TileLoader.nextTile);
			Array.Resize<bool>(ref TileID.Sets.BlocksStairs, TileLoader.nextTile);
			Array.Resize<bool>(ref TileID.Sets.BlocksStairsAbove, TileLoader.nextTile);
			Array.Resize<bool>(ref TileID.Sets.NotReallySolid, TileLoader.nextTile);
			Array.Resize<bool>(ref TileID.Sets.NeedsGrassFraming, TileLoader.nextTile);
			Array.Resize<int>(ref TileID.Sets.NeedsGrassFramingDirt, TileLoader.nextTile);
			Array.Resize<bool>(ref TileID.Sets.ChecksForMerge, TileLoader.nextTile);
			Array.Resize<bool>(ref TileID.Sets.FramesOnKillWall, TileLoader.nextTile);
			Array.Resize<bool>(ref TileID.Sets.AvoidedByNPCs, TileLoader.nextTile);
			Array.Resize<bool>(ref TileID.Sets.InteractibleByNPCs, TileLoader.nextTile);
			Array.Resize<bool>(ref TileID.Sets.HousingWalls, TileLoader.nextTile);
			Array.Resize<bool>(ref TileID.Sets.BreakableWhenPlacing, TileLoader.nextTile);
			Array.Resize<int>(ref TileID.Sets.TouchDamageVines, TileLoader.nextTile);
			Array.Resize<int>(ref TileID.Sets.TouchDamageSands, TileLoader.nextTile);
			Array.Resize<int>(ref TileID.Sets.TouchDamageHot, TileLoader.nextTile);
			Array.Resize<int>(ref TileID.Sets.TouchDamageOther, TileLoader.nextTile);
			Array.Resize<bool>(ref TileID.Sets.Falling, TileLoader.nextTile);
			Array.Resize<bool>(ref TileID.Sets.Ore, TileLoader.nextTile);
			Array.Resize<bool>(ref TileID.Sets.ForceObsidianKill, TileLoader.nextTile);
			for (int k = 470; k < TileLoader.nextTile; k++)
			{
				TileID.Sets.AllTiles[k] = true;
				TileID.Sets.GeneralPlacementTiles[k] = true;
				TileID.Sets.CanBeClearedDuringGeneration[k] = true;
			}
			while (TileObjectData._data.Count < TileLoader.nextTile)
			{
				TileObjectData._data.Add(null);
			}
			ModLoader.BuildGlobalHook<GlobalTile, Func<int, int, int, bool>>(ref TileLoader.HookKillSound, TileLoader.globalTiles, (GlobalTile g) => (Func<int, int, int, bool>)Delegate.CreateDelegate(typeof(Func<int, int, int, bool>), g, methodof(GlobalTile.KillSound(int, int, int))));
			ModLoader.BuildGlobalHook<GlobalTile, TileLoader.DelegateNumDust>(ref TileLoader.HookNumDust, TileLoader.globalTiles, (GlobalTile g) => (TileLoader.DelegateNumDust)Delegate.CreateDelegate(typeof(TileLoader.DelegateNumDust), g, methodof(GlobalTile.NumDust(int, int, int, bool, int*))));
			ModLoader.BuildGlobalHook<GlobalTile, TileLoader.DelegateCreateDust>(ref TileLoader.HookCreateDust, TileLoader.globalTiles, (GlobalTile g) => (TileLoader.DelegateCreateDust)Delegate.CreateDelegate(typeof(TileLoader.DelegateCreateDust), g, methodof(GlobalTile.CreateDust(int, int, int, int*))));
			ModLoader.BuildGlobalHook<GlobalTile, TileLoader.DelegateDropCritterChance>(ref TileLoader.HookDropCritterChance, TileLoader.globalTiles, (GlobalTile g) => (TileLoader.DelegateDropCritterChance)Delegate.CreateDelegate(typeof(TileLoader.DelegateDropCritterChance), g, methodof(GlobalTile.DropCritterChance(int, int, int, int*, int*, int*))));
			ModLoader.BuildGlobalHook<GlobalTile, Func<int, int, int, bool>>(ref TileLoader.HookDrop, TileLoader.globalTiles, (GlobalTile g) => (Func<int, int, int, bool>)Delegate.CreateDelegate(typeof(Func<int, int, int, bool>), g, methodof(GlobalTile.Drop(int, int, int))));
			ModLoader.BuildGlobalHook<GlobalTile, TileLoader.DelegateCanKillTile>(ref TileLoader.HookCanKillTile, TileLoader.globalTiles, (GlobalTile g) => (TileLoader.DelegateCanKillTile)Delegate.CreateDelegate(typeof(TileLoader.DelegateCanKillTile), g, methodof(GlobalTile.CanKillTile(int, int, int, bool*))));
			ModLoader.BuildGlobalHook<GlobalTile, TileLoader.DelegateKillTile>(ref TileLoader.HookKillTile, TileLoader.globalTiles, (GlobalTile g) => (TileLoader.DelegateKillTile)Delegate.CreateDelegate(typeof(TileLoader.DelegateKillTile), g, methodof(GlobalTile.KillTile(int, int, int, bool*, bool*, bool*))));
			ModLoader.BuildGlobalHook<GlobalTile, Func<int, int, int, bool>>(ref TileLoader.HookCanExplode, TileLoader.globalTiles, (GlobalTile g) => (Func<int, int, int, bool>)Delegate.CreateDelegate(typeof(Func<int, int, int, bool>), g, methodof(GlobalTile.CanExplode(int, int, int))));
			ModLoader.BuildGlobalHook<GlobalTile, Action<int, int, int, bool>>(ref TileLoader.HookNearbyEffects, TileLoader.globalTiles, (GlobalTile g) => (Action<int, int, int, bool>)Delegate.CreateDelegate(typeof(Action<int, int, int, bool>), g, methodof(GlobalTile.NearbyEffects(int, int, int, bool))));
			ModLoader.BuildGlobalHook<GlobalTile, TileLoader.DelegateModifyLight>(ref TileLoader.HookModifyLight, TileLoader.globalTiles, (GlobalTile g) => (TileLoader.DelegateModifyLight)Delegate.CreateDelegate(typeof(TileLoader.DelegateModifyLight), g, methodof(GlobalTile.ModifyLight(int, int, int, float*, float*, float*))));
			ModLoader.BuildGlobalHook<GlobalTile, Func<int, int, int, Player, bool>>(ref TileLoader.HookDangersense, TileLoader.globalTiles, (GlobalTile g) => (Func<int, int, int, Player, bool>)Delegate.CreateDelegate(typeof(Func<int, int, int, Player, bool>), g, methodof(GlobalTile.Dangersense(int, int, int, Player))));
			ModLoader.BuildGlobalHook<GlobalTile, TileLoader.DelegateSetSpriteEffects>(ref TileLoader.HookSetSpriteEffects, TileLoader.globalTiles, (GlobalTile g) => (TileLoader.DelegateSetSpriteEffects)Delegate.CreateDelegate(typeof(TileLoader.DelegateSetSpriteEffects), g, methodof(GlobalTile.SetSpriteEffects(int, int, int, SpriteEffects*))));
			ModLoader.BuildGlobalHook<GlobalTile, Action>(ref TileLoader.HookAnimateTile, TileLoader.globalTiles, (GlobalTile g) => (Action)Delegate.CreateDelegate(typeof(Action), g, methodof(GlobalTile.AnimateTile())));
			ModLoader.BuildGlobalHook<GlobalTile, Func<int, int, int, SpriteBatch, bool>>(ref TileLoader.HookPreDraw, TileLoader.globalTiles, (GlobalTile g) => (Func<int, int, int, SpriteBatch, bool>)Delegate.CreateDelegate(typeof(Func<int, int, int, SpriteBatch, bool>), g, methodof(GlobalTile.PreDraw(int, int, int, SpriteBatch))));
			ModLoader.BuildGlobalHook<GlobalTile, TileLoader.DelegateDrawEffects>(ref TileLoader.HookDrawEffects, TileLoader.globalTiles, (GlobalTile g) => (TileLoader.DelegateDrawEffects)Delegate.CreateDelegate(typeof(TileLoader.DelegateDrawEffects), g, methodof(GlobalTile.DrawEffects(int, int, int, SpriteBatch, Color*, int*))));
			ModLoader.BuildGlobalHook<GlobalTile, Action<int, int, int, SpriteBatch>>(ref TileLoader.HookPostDraw, TileLoader.globalTiles, (GlobalTile g) => (Action<int, int, int, SpriteBatch>)Delegate.CreateDelegate(typeof(Action<int, int, int, SpriteBatch>), g, methodof(GlobalTile.PostDraw(int, int, int, SpriteBatch))));
			ModLoader.BuildGlobalHook<GlobalTile, Action<int, int, int, SpriteBatch>>(ref TileLoader.HookSpecialDraw, TileLoader.globalTiles, (GlobalTile g) => (Action<int, int, int, SpriteBatch>)Delegate.CreateDelegate(typeof(Action<int, int, int, SpriteBatch>), g, methodof(GlobalTile.SpecialDraw(int, int, int, SpriteBatch))));
			ModLoader.BuildGlobalHook<GlobalTile, Action<int, int, int>>(ref TileLoader.HookRandomUpdate, TileLoader.globalTiles, (GlobalTile g) => (Action<int, int, int>)Delegate.CreateDelegate(typeof(Action<int, int, int>), g, methodof(GlobalTile.RandomUpdate(int, int, int))));
			ModLoader.BuildGlobalHook<GlobalTile, TileLoader.DelegateTileFrame>(ref TileLoader.HookTileFrame, TileLoader.globalTiles, (GlobalTile g) => (TileLoader.DelegateTileFrame)Delegate.CreateDelegate(typeof(TileLoader.DelegateTileFrame), g, methodof(GlobalTile.TileFrame(int, int, int, bool*, bool*))));
			ModLoader.BuildGlobalHook<GlobalTile, Func<int, int, int, bool>>(ref TileLoader.HookCanPlace, TileLoader.globalTiles, (GlobalTile g) => (Func<int, int, int, bool>)Delegate.CreateDelegate(typeof(Func<int, int, int, bool>), g, methodof(GlobalTile.CanPlace(int, int, int))));
			ModLoader.BuildGlobalHook<GlobalTile, Func<int, int[]>>(ref TileLoader.HookAdjTiles, TileLoader.globalTiles, (GlobalTile g) => (Func<int, int[]>)Delegate.CreateDelegate(typeof(Func<int, int[]>), g, methodof(GlobalTile.AdjTiles(int))));
			ModLoader.BuildGlobalHook<GlobalTile, Action<int, int, int>>(ref TileLoader.HookRightClick, TileLoader.globalTiles, (GlobalTile g) => (Action<int, int, int>)Delegate.CreateDelegate(typeof(Action<int, int, int>), g, methodof(GlobalTile.RightClick(int, int, int))));
			ModLoader.BuildGlobalHook<GlobalTile, Action<int, int, int>>(ref TileLoader.HookMouseOver, TileLoader.globalTiles, (GlobalTile g) => (Action<int, int, int>)Delegate.CreateDelegate(typeof(Action<int, int, int>), g, methodof(GlobalTile.MouseOver(int, int, int))));
			ModLoader.BuildGlobalHook<GlobalTile, Action<int, int, int>>(ref TileLoader.HookMouseOverFar, TileLoader.globalTiles, (GlobalTile g) => (Action<int, int, int>)Delegate.CreateDelegate(typeof(Action<int, int, int>), g, methodof(GlobalTile.MouseOverFar(int, int, int))));
			ModLoader.BuildGlobalHook<GlobalTile, Func<int, int, int, Item, bool>>(ref TileLoader.HookAutoSelect, TileLoader.globalTiles, (GlobalTile g) => (Func<int, int, int, Item, bool>)Delegate.CreateDelegate(typeof(Func<int, int, int, Item, bool>), g, methodof(GlobalTile.AutoSelect(int, int, int, Item))));
			ModLoader.BuildGlobalHook<GlobalTile, Func<int, int, int, bool>>(ref TileLoader.HookPreHitWire, TileLoader.globalTiles, (GlobalTile g) => (Func<int, int, int, bool>)Delegate.CreateDelegate(typeof(Func<int, int, int, bool>), g, methodof(GlobalTile.PreHitWire(int, int, int))));
			ModLoader.BuildGlobalHook<GlobalTile, Action<int, int, int>>(ref TileLoader.HookHitWire, TileLoader.globalTiles, (GlobalTile g) => (Action<int, int, int>)Delegate.CreateDelegate(typeof(Action<int, int, int>), g, methodof(GlobalTile.HitWire(int, int, int))));
			ModLoader.BuildGlobalHook<GlobalTile, Func<int, int, int, bool>>(ref TileLoader.HookSlope, TileLoader.globalTiles, (GlobalTile g) => (Func<int, int, int, bool>)Delegate.CreateDelegate(typeof(Func<int, int, int, bool>), g, methodof(GlobalTile.Slope(int, int, int))));
			ModLoader.BuildGlobalHook<GlobalTile, Action<int, Player>>(ref TileLoader.HookFloorVisuals, TileLoader.globalTiles, (GlobalTile g) => (Action<int, Player>)Delegate.CreateDelegate(typeof(Action<int, Player>), g, methodof(GlobalTile.FloorVisuals(int, Player))));
			ModLoader.BuildGlobalHook<GlobalTile, TileLoader.DelegateChangeWaterfallStyle>(ref TileLoader.HookChangeWaterfallStyle, TileLoader.globalTiles, (GlobalTile g) => (TileLoader.DelegateChangeWaterfallStyle)Delegate.CreateDelegate(typeof(TileLoader.DelegateChangeWaterfallStyle), g, methodof(GlobalTile.ChangeWaterfallStyle(int, int*))));
			ModLoader.BuildGlobalHook<GlobalTile, TileLoader.DelegateSaplingGrowthType>(ref TileLoader.HookSaplingGrowthType, TileLoader.globalTiles, (GlobalTile g) => (TileLoader.DelegateSaplingGrowthType)Delegate.CreateDelegate(typeof(TileLoader.DelegateSaplingGrowthType), g, methodof(GlobalTile.SaplingGrowthType(int, int*))));
			ModLoader.BuildGlobalHook<GlobalTile, Action<int, int, Item>>(ref TileLoader.HookPlaceInWorld, TileLoader.globalTiles, (GlobalTile g) => (Action<int, int, Item>)Delegate.CreateDelegate(typeof(Action<int, int, Item>), g, methodof(GlobalTile.PlaceInWorld(int, int, Item))));
			if (!unloading)
			{
				TileLoader.loaded = true;
			}
		}

		// Token: 0x06001874 RID: 6260 RVA: 0x0042018C File Offset: 0x0041E38C
		internal static void Unload()
		{
			TileLoader.loaded = false;
			TileLoader.tiles.Clear();
			TileLoader.nextTile = 470;
			TileLoader.globalTiles.Clear();
			TileLoader.trees.Clear();
			TileLoader.palmTrees.Clear();
			TileLoader.cacti.Clear();
			Array.Resize<int>(ref TileID.Sets.RoomNeeds.CountsAsChair, TileLoader.vanillaChairCount);
			Array.Resize<int>(ref TileID.Sets.RoomNeeds.CountsAsTable, TileLoader.vanillaTableCount);
			Array.Resize<int>(ref TileID.Sets.RoomNeeds.CountsAsTorch, TileLoader.vanillaTorchCount);
			Array.Resize<int>(ref TileID.Sets.RoomNeeds.CountsAsDoor, TileLoader.vanillaDoorCount);
			while (TileObjectData._data.Count > 470)
			{
				TileObjectData._data.RemoveAt(TileObjectData._data.Count - 1);
			}
		}

		// Token: 0x06001875 RID: 6261 RVA: 0x00420240 File Offset: 0x0041E440
		public static void CheckModTile(int i, int j, int type)
		{
			if (WorldGen.destroyObject)
			{
				return;
			}
			TileObjectData tileData = TileObjectData.GetTileData(type, 0, 0);
			if (tileData == null)
			{
				return;
			}
			int frameX = (int)Main.tile[i, j].frameX;
			int frameY = (int)Main.tile[i, j].frameY;
			int num = frameX / tileData.CoordinateFullWidth;
			int num2 = frameY / tileData.CoordinateFullHeight;
			int num3 = tileData.StyleWrapLimit;
			if (num3 == 0)
			{
				num3 = 1;
			}
			int num4 = tileData.StyleHorizontal ? (num2 * num3 + num) : (num * num3 + num2);
			int style = num4 / tileData.StyleMultiplier;
			int num5 = num4 % tileData.StyleMultiplier;
			for (int k = 0; k < tileData.AlternatesCount; k++)
			{
				if (num5 >= tileData.Alternates[k].Style && num5 <= tileData.Alternates[k].Style + tileData.RandomStyleRange)
				{
					num5 = k;
					break;
				}
			}
			tileData = TileObjectData.GetTileData(type, style, num5 + 1);
			int num6 = frameX % tileData.CoordinateFullWidth;
			int num7 = frameY % tileData.CoordinateFullHeight;
			int num8 = num6 / (tileData.CoordinateWidth + tileData.CoordinatePadding);
			int num9 = 0;
			int l = num7;
			while (l > 0)
			{
				l -= tileData.CoordinateHeights[num9] + tileData.CoordinatePadding;
				num9++;
			}
			i -= num8;
			j -= num9;
			int x = i + (int)tileData.Origin.X;
			int y = j + (int)tileData.Origin.Y;
			bool flag = false;
			for (int m = i; m < i + tileData.Width; m++)
			{
				for (int n = j; n < j + tileData.Height; n++)
				{
					if (!Main.tile[m, n].active() || (int)Main.tile[m, n].type != type)
					{
						flag = true;
						break;
					}
				}
				if (flag)
				{
					break;
				}
			}
			TileObject tileObject;
			if (flag || !TileObject.CanPlace(x, y, type, style, 0, out tileObject, true, true))
			{
				WorldGen.destroyObject = true;
				for (int num10 = i; num10 < i + tileData.Width; num10++)
				{
					for (int num11 = j; num11 < j + tileData.Height; num11++)
					{
						if ((int)Main.tile[num10, num11].type == type && Main.tile[num10, num11].active())
						{
							WorldGen.KillTile(num10, num11, false, false, false);
						}
					}
				}
				TileLoader.KillMultiTile(i, j, frameX - num6, frameY - num7, type);
				WorldGen.destroyObject = false;
				for (int num12 = i - 1; num12 < i + tileData.Width + 2; num12++)
				{
					for (int num13 = j - 1; num13 < j + tileData.Height + 2; num13++)
					{
						WorldGen.TileFrame(num12, num13, false, false);
					}
				}
			}
			TileObject.objectPreview.Active = false;
		}

		// Token: 0x06001876 RID: 6262 RVA: 0x004204F8 File Offset: 0x0041E6F8
		public static void DisableSmartCursor(Tile tile, ref bool disable)
		{
			if (tile.active())
			{
				ModTile tile2 = TileLoader.GetTile((int)tile.type);
				if (tile2 != null)
				{
					disable = tile2.disableSmartCursor;
				}
			}
		}

		// Token: 0x06001877 RID: 6263 RVA: 0x00420524 File Offset: 0x0041E724
		public static void DisableSmartInteract(Tile tile, ref bool disable)
		{
			if (tile.active())
			{
				ModTile tile2 = TileLoader.GetTile((int)tile.type);
				if (tile2 != null)
				{
					disable = tile2.disableSmartInteract;
				}
			}
		}

		// Token: 0x06001878 RID: 6264 RVA: 0x00420550 File Offset: 0x0041E750
		public static int OpenDoorID(Tile tile)
		{
			ModTile tile2 = TileLoader.GetTile((int)tile.type);
			if (tile2 != null)
			{
				return tile2.openDoorID;
			}
			if (tile.type == 10 && (tile.frameY < 594 || tile.frameY > 646 || tile.frameX >= 54))
			{
				return 11;
			}
			return -1;
		}

		// Token: 0x06001879 RID: 6265 RVA: 0x004205A8 File Offset: 0x0041E7A8
		public static int CloseDoorID(Tile tile)
		{
			ModTile tile2 = TileLoader.GetTile((int)tile.type);
			if (tile2 != null)
			{
				return tile2.closeDoorID;
			}
			if (tile.type == 11)
			{
				return 10;
			}
			return -1;
		}

		// Token: 0x0600187A RID: 6266 RVA: 0x004205DC File Offset: 0x0041E7DC
		public static bool IsClosedDoor(Tile tile)
		{
			ModTile tile2 = TileLoader.GetTile((int)tile.type);
			if (tile2 != null)
			{
				return tile2.openDoorID > -1;
			}
			return tile.type == 10;
		}

		// Token: 0x0600187B RID: 6267 RVA: 0x0042060C File Offset: 0x0041E80C
		public static string ModChestName(int type)
		{
			ModTile tile = TileLoader.GetTile(type);
			if (tile != null)
			{
				return tile.chest;
			}
			return "";
		}

		// Token: 0x0600187C RID: 6268 RVA: 0x00012002 File Offset: 0x00010202
		public static bool IsDresser(int type)
		{
			return type == 88 || TileLoader.ModDresserName(type).Length > 0;
		}

		// Token: 0x0600187D RID: 6269 RVA: 0x00420630 File Offset: 0x0041E830
		public static string ModDresserName(int type)
		{
			ModTile tile = TileLoader.GetTile(type);
			if (tile != null)
			{
				return tile.dresser;
			}
			return "";
		}

		// Token: 0x0600187E RID: 6270 RVA: 0x00420654 File Offset: 0x0041E854
		public static bool IsModBed(int type)
		{
			ModTile tile = TileLoader.GetTile(type);
			return tile != null && tile.bed;
		}

		// Token: 0x0600187F RID: 6271 RVA: 0x00420674 File Offset: 0x0041E874
		public static bool IsTorch(int type)
		{
			ModTile tile = TileLoader.GetTile(type);
			if (tile == null)
			{
				return type == 4;
			}
			return tile.torch;
		}

		// Token: 0x06001880 RID: 6272 RVA: 0x00420698 File Offset: 0x0041E898
		public static bool IsSapling(int type)
		{
			ModTile tile = TileLoader.GetTile(type);
			if (tile == null)
			{
				return type == 20;
			}
			return tile.sapling;
		}

		// Token: 0x06001881 RID: 6273 RVA: 0x00012019 File Offset: 0x00010219
		public static bool IsModMusicBox(Tile tile)
		{
			return SoundLoader.tileToMusic.ContainsKey((int)tile.type) && SoundLoader.tileToMusic[(int)tile.type].ContainsKey((int)(tile.frameY / 36 * 36));
		}

		// Token: 0x06001882 RID: 6274 RVA: 0x004206BC File Offset: 0x0041E8BC
		internal static void SetDefaults(ModTile tile)
		{
			tile.SetDefaults();
			if (TileObjectData.newTile.Width > 1 || TileObjectData.newTile.Height > 1)
			{
				TileObjectData.FixNewTile();
				throw new Exception("It appears that you have an error surrounding TileObjectData.AddTile in " + tile.GetType().FullName)
				{
					HelpLink = "https://github.com/blushiemagic/tModLoader/wiki/Basic-tModLoader-Modding-FAQ#tileobjectdataaddtile-issues"
				};
			}
			if (Main.tileLavaDeath[(int)tile.Type])
			{
				Main.tileObsidianKill[(int)tile.Type] = true;
			}
			if (Main.tileSolid[(int)tile.Type])
			{
				Main.tileNoSunLight[(int)tile.Type] = true;
			}
			tile.PostSetDefaults();
		}

		// Token: 0x06001883 RID: 6275 RVA: 0x00012050 File Offset: 0x00010250
		public static bool HasSmartInteract(int type)
		{
			ModTile tile = TileLoader.GetTile(type);
			return tile != null && tile.HasSmartInteract();
		}

		// Token: 0x06001884 RID: 6276 RVA: 0x00420750 File Offset: 0x0041E950
		public static void FixSmartInteractCoords(int type, ref int width, ref int height, ref int frameWidth, ref int frameHeight, ref int extraX, ref int extraY)
		{
			ModTile tile = TileLoader.GetTile(type);
			if (tile != null)
			{
				TileObjectData tileData = TileObjectData.GetTileData(type, 0, 0);
				width = tileData.Width;
				height = tileData.Height;
				frameWidth = tileData.CoordinateWidth + tileData.CoordinatePadding;
				frameHeight = tileData.CoordinateHeights[0] + tileData.CoordinatePadding;
				extraY = tileData.CoordinateFullHeight % frameHeight;
			}
		}

		// Token: 0x06001885 RID: 6277 RVA: 0x004207B0 File Offset: 0x0041E9B0
		public static bool KillSound(int i, int j, int type)
		{
			foreach (Func<int, int, int, bool> func in TileLoader.HookKillSound)
			{
				if (!func(i, j, type))
				{
					return false;
				}
			}
			ModTile tile = TileLoader.GetTile(type);
			if (tile == null)
			{
				return true;
			}
			if (!tile.KillSound(i, j))
			{
				return false;
			}
			Main.PlaySound(tile.soundType, i * 16, j * 16, tile.soundStyle, 1f, 0f);
			return false;
		}

		// Token: 0x06001886 RID: 6278 RVA: 0x00420820 File Offset: 0x0041EA20
		public static void NumDust(int i, int j, int type, bool fail, ref int numDust)
		{
			ModTile tile = TileLoader.GetTile(type);
			if (tile != null)
			{
				tile.NumDust(i, j, fail, ref numDust);
			}
			foreach (TileLoader.DelegateNumDust delegateNumDust in TileLoader.HookNumDust)
			{
				delegateNumDust(i, j, type, fail, ref numDust);
			}
		}

		// Token: 0x06001887 RID: 6279 RVA: 0x00420868 File Offset: 0x0041EA68
		public static bool CreateDust(int i, int j, int type, ref int dustType)
		{
			foreach (TileLoader.DelegateCreateDust delegateCreateDust in TileLoader.HookCreateDust)
			{
				if (!delegateCreateDust(i, j, type, ref dustType))
				{
					return false;
				}
			}
			ModTile tile = TileLoader.GetTile(type);
			return tile == null || tile.CreateDust(i, j, ref dustType);
		}

		// Token: 0x06001888 RID: 6280 RVA: 0x004208B0 File Offset: 0x0041EAB0
		public static void DropCritterChance(int i, int j, int type, ref int wormChance, ref int grassHopperChance, ref int jungleGrubChance)
		{
			ModTile tile = TileLoader.GetTile(type);
			if (tile != null)
			{
				tile.DropCritterChance(i, j, ref wormChance, ref grassHopperChance, ref jungleGrubChance);
			}
			foreach (TileLoader.DelegateDropCritterChance delegateDropCritterChance in TileLoader.HookDropCritterChance)
			{
				delegateDropCritterChance(i, j, type, ref wormChance, ref grassHopperChance, ref jungleGrubChance);
			}
		}

		// Token: 0x06001889 RID: 6281 RVA: 0x004208FC File Offset: 0x0041EAFC
		public static bool Drop(int i, int j, int type)
		{
			foreach (Func<int, int, int, bool> func in TileLoader.HookDrop)
			{
				if (!func(i, j, type))
				{
					return false;
				}
			}
			ModTile tile = TileLoader.GetTile(type);
			if (tile == null)
			{
				return true;
			}
			if (!tile.Drop(i, j))
			{
				return false;
			}
			if (tile.drop > 0)
			{
				Item.NewItem(i * 16, j * 16, 16, 16, tile.drop, 1, false, -1, false, false);
			}
			return false;
		}

		// Token: 0x0600188A RID: 6282 RVA: 0x00420970 File Offset: 0x0041EB70
		public static bool CanKillTile(int i, int j, int type, ref bool blockDamaged)
		{
			foreach (TileLoader.DelegateCanKillTile delegateCanKillTile in TileLoader.HookCanKillTile)
			{
				if (!delegateCanKillTile(i, j, type, ref blockDamaged))
				{
					return false;
				}
			}
			ModTile tile = TileLoader.GetTile(type);
			return tile == null || tile.CanKillTile(i, j, ref blockDamaged);
		}

		// Token: 0x0600188B RID: 6283 RVA: 0x004209B8 File Offset: 0x0041EBB8
		public static void KillTile(int i, int j, int type, ref bool fail, ref bool effectOnly, ref bool noItem)
		{
			ModTile tile = TileLoader.GetTile(type);
			if (tile != null)
			{
				tile.KillTile(i, j, ref fail, ref effectOnly, ref noItem);
			}
			foreach (TileLoader.DelegateKillTile delegateKillTile in TileLoader.HookKillTile)
			{
				delegateKillTile(i, j, type, ref fail, ref effectOnly, ref noItem);
			}
		}

		// Token: 0x0600188C RID: 6284 RVA: 0x00012063 File Offset: 0x00010263
		public static void KillMultiTile(int i, int j, int frameX, int frameY, int type)
		{
			ModTile tile = TileLoader.GetTile(type);
			if (tile == null)
			{
				return;
			}
			tile.KillMultiTile(i, j, frameX, frameY);
		}

		// Token: 0x0600188D RID: 6285 RVA: 0x00420A04 File Offset: 0x0041EC04
		public static bool CanExplode(int i, int j)
		{
			int type = (int)Main.tile[i, j].type;
			ModTile tile = TileLoader.GetTile(type);
			if (tile != null && !tile.CanExplode(i, j))
			{
				return false;
			}
			foreach (Func<int, int, int, bool> func in TileLoader.HookCanExplode)
			{
				if (!func(i, j, type))
				{
					return false;
				}
			}
			return true;
		}

		// Token: 0x0600188E RID: 6286 RVA: 0x00420A64 File Offset: 0x0041EC64
		public static void NearbyEffects(int i, int j, int type, bool closer)
		{
			ModTile tile = TileLoader.GetTile(type);
			if (tile != null)
			{
				tile.NearbyEffects(i, j, closer);
			}
			foreach (Action<int, int, int, bool> action in TileLoader.HookNearbyEffects)
			{
				action(i, j, type, closer);
			}
		}

		// Token: 0x0600188F RID: 6287 RVA: 0x00420AA8 File Offset: 0x0041ECA8
		public static void ModifyLight(int i, int j, int type, ref float r, ref float g, ref float b)
		{
			if (!Main.tileLighted[type])
			{
				return;
			}
			ModTile tile = TileLoader.GetTile(type);
			if (tile != null)
			{
				tile.ModifyLight(i, j, ref r, ref g, ref b);
			}
			foreach (TileLoader.DelegateModifyLight delegateModifyLight in TileLoader.HookModifyLight)
			{
				delegateModifyLight(i, j, type, ref r, ref g, ref b);
			}
		}

		// Token: 0x06001890 RID: 6288 RVA: 0x00420B00 File Offset: 0x0041ED00
		public static bool Dangersense(int i, int j, int type, Player player)
		{
			ModTile tile = TileLoader.GetTile(type);
			if (tile != null && tile.Dangersense(i, j, player))
			{
				return true;
			}
			foreach (Func<int, int, int, Player, bool> func in TileLoader.HookDangersense)
			{
				if (func(i, j, type, player))
				{
					return true;
				}
			}
			return false;
		}

		// Token: 0x06001891 RID: 6289 RVA: 0x00420B4C File Offset: 0x0041ED4C
		public static void SetSpriteEffects(int i, int j, int type, ref SpriteEffects spriteEffects)
		{
			ModTile tile = TileLoader.GetTile(type);
			if (tile != null)
			{
				tile.SetSpriteEffects(i, j, ref spriteEffects);
			}
			foreach (TileLoader.DelegateSetSpriteEffects delegateSetSpriteEffects in TileLoader.HookSetSpriteEffects)
			{
				delegateSetSpriteEffects(i, j, type, ref spriteEffects);
			}
		}

		// Token: 0x06001892 RID: 6290 RVA: 0x00420B90 File Offset: 0x0041ED90
		public static void SetDrawPositions(int i, int j, ref int width, ref int offsetY, ref int height)
		{
			Tile tile = Main.tile[i, j];
			if (tile.type >= 470)
			{
				TileObjectData tileData = TileObjectData.GetTileData((int)tile.type, 0, 0);
				if (tileData != null)
				{
					int k = (int)tile.frameY % tileData.CoordinateFullHeight;
					int num = 0;
					while (k > 0)
					{
						k -= tileData.CoordinateHeights[num] + tileData.CoordinatePadding;
						num++;
					}
					width = tileData.CoordinateWidth;
					offsetY = tileData.DrawYOffset;
					height = tileData.CoordinateHeights[num];
				}
				TileLoader.GetTile((int)tile.type).SetDrawPositions(i, j, ref width, ref offsetY, ref height);
			}
		}

		// Token: 0x06001893 RID: 6291 RVA: 0x00420C28 File Offset: 0x0041EE28
		public static void AnimateTiles()
		{
			if (TileLoader.loaded)
			{
				for (int i = 0; i < TileLoader.tiles.Count; i++)
				{
					ModTile modTile = TileLoader.tiles[i];
					modTile.AnimateTile(ref Main.tileFrame[(int)modTile.Type], ref Main.tileFrameCounter[(int)modTile.Type]);
				}
				foreach (Action action in TileLoader.HookAnimateTile)
				{
					action();
				}
			}
		}

		// Token: 0x06001894 RID: 6292 RVA: 0x00420CA4 File Offset: 0x0041EEA4
		public static void SetAnimationFrame(int type, int i, int j, ref int frameXOffset, ref int frameYOffset)
		{
			ModTile tile = TileLoader.GetTile(type);
			if (tile != null)
			{
				frameYOffset = tile.animationFrameHeight * Main.tileFrame[type];
				tile.AnimateIndividualTile(type, i, j, ref frameXOffset, ref frameYOffset);
			}
		}

		// Token: 0x06001895 RID: 6293 RVA: 0x00420CD8 File Offset: 0x0041EED8
		public static bool PreDraw(int i, int j, int type, SpriteBatch spriteBatch)
		{
			foreach (Func<int, int, int, SpriteBatch, bool> func in TileLoader.HookPreDraw)
			{
				if (!func(i, j, type, spriteBatch))
				{
					return false;
				}
			}
			ModTile tile = TileLoader.GetTile(type);
			return tile == null || tile.PreDraw(i, j, spriteBatch);
		}

		// Token: 0x06001896 RID: 6294 RVA: 0x00420D20 File Offset: 0x0041EF20
		public static void DrawEffects(int i, int j, int type, SpriteBatch spriteBatch, ref Color drawColor, ref int nextSpecialDrawIndex)
		{
			ModTile tile = TileLoader.GetTile(type);
			if (tile != null)
			{
				tile.DrawEffects(i, j, spriteBatch, ref drawColor, ref nextSpecialDrawIndex);
			}
			foreach (TileLoader.DelegateDrawEffects delegateDrawEffects in TileLoader.HookDrawEffects)
			{
				delegateDrawEffects(i, j, type, spriteBatch, ref drawColor, ref nextSpecialDrawIndex);
			}
		}

		// Token: 0x06001897 RID: 6295 RVA: 0x00420D6C File Offset: 0x0041EF6C
		public static void PostDraw(int i, int j, int type, SpriteBatch spriteBatch)
		{
			ModTile tile = TileLoader.GetTile(type);
			if (tile != null)
			{
				tile.PostDraw(i, j, spriteBatch);
			}
			foreach (Action<int, int, int, SpriteBatch> action in TileLoader.HookPostDraw)
			{
				action(i, j, type, spriteBatch);
			}
		}

		// Token: 0x06001898 RID: 6296 RVA: 0x00420DB0 File Offset: 0x0041EFB0
		public static void SpecialDraw(int type, int specX, int specY, SpriteBatch spriteBatch)
		{
			ModTile tile = TileLoader.GetTile(type);
			if (tile != null)
			{
				tile.SpecialDraw(specX, specY, spriteBatch);
			}
			foreach (Action<int, int, int, SpriteBatch> action in TileLoader.HookSpecialDraw)
			{
				action(specX, specY, type, spriteBatch);
			}
		}

		// Token: 0x06001899 RID: 6297 RVA: 0x00420DF4 File Offset: 0x0041EFF4
		public static void RandomUpdate(int i, int j, int type)
		{
			if (!Main.tile[i, j].active())
			{
				return;
			}
			ModTile tile = TileLoader.GetTile(type);
			if (tile != null)
			{
				tile.RandomUpdate(i, j);
			}
			foreach (Action<int, int, int> action in TileLoader.HookRandomUpdate)
			{
				action(i, j, type);
			}
		}

		// Token: 0x0600189A RID: 6298 RVA: 0x00420E4C File Offset: 0x0041F04C
		public static bool TileFrame(int i, int j, int type, ref bool resetFrame, ref bool noBreak)
		{
			ModTile tile = TileLoader.GetTile(type);
			bool flag = true;
			if (tile != null)
			{
				flag = tile.TileFrame(i, j, ref resetFrame, ref noBreak);
			}
			foreach (TileLoader.DelegateTileFrame delegateTileFrame in TileLoader.HookTileFrame)
			{
				flag &= delegateTileFrame(i, j, type, ref resetFrame, ref noBreak);
			}
			return flag;
		}

		// Token: 0x0600189B RID: 6299 RVA: 0x00420E9C File Offset: 0x0041F09C
		public static void MineDamage(int minePower, ref int damage)
		{
			Tile tile = Main.tile[Player.tileTargetX, Player.tileTargetY];
			ModTile tile2 = TileLoader.GetTile((int)tile.type);
			damage += ((tile2 != null) ? ((int)((float)minePower / tile2.mineResist)) : minePower);
		}

		// Token: 0x0600189C RID: 6300 RVA: 0x00420EE0 File Offset: 0x0041F0E0
		public static void PickPowerCheck(Tile target, int pickPower, ref int damage)
		{
			ModTile tile = TileLoader.GetTile((int)target.type);
			if (tile != null && pickPower < tile.minPick)
			{
				damage = 0;
			}
		}

		// Token: 0x0600189D RID: 6301 RVA: 0x00420F08 File Offset: 0x0041F108
		public static bool CanPlace(int i, int j, int type)
		{
			foreach (Func<int, int, int, bool> func in TileLoader.HookCanPlace)
			{
				if (!func(i, j, type))
				{
					return false;
				}
			}
			ModTile tile = TileLoader.GetTile(type);
			return tile == null || tile.CanPlace(i, j);
		}

		// Token: 0x0600189E RID: 6302 RVA: 0x00420F50 File Offset: 0x0041F150
		public static void AdjTiles(Player player, int type)
		{
			ModTile tile = TileLoader.GetTile(type);
			if (tile != null)
			{
				foreach (int num in tile.adjTiles)
				{
					player.adjTile[num] = true;
				}
			}
			foreach (Func<int, int[]> func in TileLoader.HookAdjTiles)
			{
				int[] array = func(type);
				foreach (int num2 in array)
				{
					player.adjTile[num2] = true;
				}
			}
		}

		// Token: 0x0600189F RID: 6303 RVA: 0x00420FDC File Offset: 0x0041F1DC
		public static void RightClick(int i, int j)
		{
			int type = (int)Main.tile[i, j].type;
			ModTile tile = TileLoader.GetTile(type);
			if (tile != null)
			{
				tile.RightClick(i, j);
			}
			foreach (Action<int, int, int> action in TileLoader.HookRightClick)
			{
				action(i, j, type);
			}
		}

		// Token: 0x060018A0 RID: 6304 RVA: 0x00421030 File Offset: 0x0041F230
		public static void MouseOver(int i, int j)
		{
			int type = (int)Main.tile[i, j].type;
			ModTile tile = TileLoader.GetTile(type);
			if (tile != null)
			{
				tile.MouseOver(i, j);
			}
			foreach (Action<int, int, int> action in TileLoader.HookMouseOver)
			{
				action(i, j, type);
			}
		}

		// Token: 0x060018A1 RID: 6305 RVA: 0x00421084 File Offset: 0x0041F284
		public static void MouseOverFar(int i, int j)
		{
			int type = (int)Main.tile[i, j].type;
			ModTile tile = TileLoader.GetTile(type);
			if (tile != null)
			{
				tile.MouseOverFar(i, j);
			}
			foreach (Action<int, int, int> action in TileLoader.HookMouseOverFar)
			{
				action(i, j, type);
			}
		}

		// Token: 0x060018A2 RID: 6306 RVA: 0x004210D8 File Offset: 0x0041F2D8
		public static int AutoSelect(int i, int j, Player player)
		{
			if (!Main.tile[i, j].active())
			{
				return -1;
			}
			int type = (int)Main.tile[i, j].type;
			ModTile tile = TileLoader.GetTile(type);
			for (int k = 0; k < 50; k++)
			{
				Item item = player.inventory[k];
				if (item.type != 0 && item.stack != 0)
				{
					if (tile != null && tile.AutoSelect(i, j, item))
					{
						return k;
					}
					foreach (Func<int, int, int, Item, bool> func in TileLoader.HookAutoSelect)
					{
						if (func(i, j, type, item))
						{
							return k;
						}
					}
				}
			}
			return -1;
		}

		// Token: 0x060018A3 RID: 6307 RVA: 0x0042117C File Offset: 0x0041F37C
		public static bool PreHitWire(int i, int j, int type)
		{
			foreach (Func<int, int, int, bool> func in TileLoader.HookPreHitWire)
			{
				if (!func(i, j, type))
				{
					return false;
				}
			}
			return true;
		}

		// Token: 0x060018A4 RID: 6308 RVA: 0x004211B0 File Offset: 0x0041F3B0
		public static void HitWire(int i, int j, int type)
		{
			ModTile tile = TileLoader.GetTile(type);
			if (tile != null)
			{
				tile.HitWire(i, j);
			}
			foreach (Action<int, int, int> action in TileLoader.HookHitWire)
			{
				action(i, j, type);
			}
		}

		// Token: 0x060018A5 RID: 6309 RVA: 0x004211F4 File Offset: 0x0041F3F4
		public static void FloorVisuals(int type, Player player)
		{
			ModTile tile = TileLoader.GetTile(type);
			if (tile != null)
			{
				tile.FloorVisuals(player);
			}
			foreach (Action<int, Player> action in TileLoader.HookFloorVisuals)
			{
				action(type, player);
			}
		}

		// Token: 0x060018A6 RID: 6310 RVA: 0x00421234 File Offset: 0x0041F434
		public static bool Slope(int i, int j, int type)
		{
			foreach (Func<int, int, int, bool> func in TileLoader.HookSlope)
			{
				if (!func(i, j, type))
				{
					return true;
				}
			}
			ModTile tile = TileLoader.GetTile(type);
			return tile != null && !tile.Slope(i, j);
		}

		// Token: 0x060018A7 RID: 6311 RVA: 0x0001207A File Offset: 0x0001027A
		public static bool HasWalkDust(int type)
		{
			ModTile tile = TileLoader.GetTile(type);
			return tile != null && tile.HasWalkDust();
		}

		// Token: 0x060018A8 RID: 6312 RVA: 0x0001208D File Offset: 0x0001028D
		public static void WalkDust(int type, ref int dustType, ref bool makeDust, ref Color color)
		{
			ModTile tile = TileLoader.GetTile(type);
			if (tile == null)
			{
				return;
			}
			tile.WalkDust(ref dustType, ref makeDust, ref color);
		}

		// Token: 0x060018A9 RID: 6313 RVA: 0x0042127C File Offset: 0x0041F47C
		public static void ChangeWaterfallStyle(int type, ref int style)
		{
			ModTile tile = TileLoader.GetTile(type);
			if (tile != null)
			{
				tile.ChangeWaterfallStyle(ref style);
			}
			foreach (TileLoader.DelegateChangeWaterfallStyle delegateChangeWaterfallStyle in TileLoader.HookChangeWaterfallStyle)
			{
				delegateChangeWaterfallStyle(type, ref style);
			}
		}

		// Token: 0x060018AA RID: 6314 RVA: 0x004212BC File Offset: 0x0041F4BC
		public static bool SaplingGrowthType(int type, ref int saplingType, ref int style)
		{
			int num = saplingType;
			int num2 = style;
			bool result = false;
			ModTile tile = TileLoader.GetTile(type);
			if (tile != null)
			{
				saplingType = tile.SaplingGrowthType(ref style);
				if (TileLoader.IsSapling(saplingType))
				{
					num = saplingType;
					num2 = style;
					result = true;
				}
				else
				{
					saplingType = num;
					style = num2;
				}
			}
			foreach (TileLoader.DelegateSaplingGrowthType delegateSaplingGrowthType in TileLoader.HookSaplingGrowthType)
			{
				saplingType = delegateSaplingGrowthType(type, ref style);
				if (TileLoader.IsSapling(saplingType))
				{
					num = saplingType;
					num2 = style;
					result = true;
				}
				else
				{
					saplingType = num;
					style = num2;
				}
			}
			return result;
		}

		// Token: 0x060018AB RID: 6315 RVA: 0x000120A2 File Offset: 0x000102A2
		public static bool CanGrowModTree(int type)
		{
			return TileLoader.trees.ContainsKey(type);
		}

		// Token: 0x060018AC RID: 6316 RVA: 0x000120AF File Offset: 0x000102AF
		public static void TreeDust(Tile tile, ref int dust)
		{
			if (tile.active() && TileLoader.trees.ContainsKey((int)tile.type))
			{
				dust = TileLoader.trees[(int)tile.type].CreateDust();
			}
		}

		// Token: 0x060018AD RID: 6317 RVA: 0x000120E2 File Offset: 0x000102E2
		public static void TreeGrowthFXGore(int type, ref int gore)
		{
			if (TileLoader.trees.ContainsKey(type))
			{
				gore = TileLoader.trees[type].GrowthFXGore();
			}
		}

		// Token: 0x060018AE RID: 6318 RVA: 0x00012103 File Offset: 0x00010303
		public static bool CanDropAcorn(int type)
		{
			return TileLoader.trees.ContainsKey(type) && TileLoader.trees[type].CanDropAcorn();
		}

		// Token: 0x060018AF RID: 6319 RVA: 0x00012124 File Offset: 0x00010324
		public static void DropTreeWood(int type, ref int wood)
		{
			if (TileLoader.trees.ContainsKey(type))
			{
				wood = TileLoader.trees[type].DropWood();
			}
		}

		// Token: 0x060018B0 RID: 6320 RVA: 0x00012145 File Offset: 0x00010345
		public static Texture2D GetTreeTexture(Tile tile)
		{
			if (!tile.active() || !TileLoader.trees.ContainsKey((int)tile.type))
			{
				return null;
			}
			return TileLoader.trees[(int)tile.type].GetTexture();
		}

		// Token: 0x060018B1 RID: 6321 RVA: 0x00012178 File Offset: 0x00010378
		public static Texture2D GetTreeTopTextures(int type, int i, int j, ref int frame, ref int frameWidth, ref int frameHeight, ref int xOffsetLeft, ref int yOffset)
		{
			if (!TileLoader.trees.ContainsKey(type))
			{
				return null;
			}
			return TileLoader.trees[type].GetTopTextures(i, j, ref frame, ref frameWidth, ref frameHeight, ref xOffsetLeft, ref yOffset);
		}

		// Token: 0x060018B2 RID: 6322 RVA: 0x000121A4 File Offset: 0x000103A4
		public static Texture2D GetTreeBranchTextures(int type, int i, int j, int trunkOffset, ref int frame)
		{
			if (!TileLoader.trees.ContainsKey(type))
			{
				return null;
			}
			return TileLoader.trees[type].GetBranchTextures(i, j, trunkOffset, ref frame);
		}

		// Token: 0x060018B3 RID: 6323 RVA: 0x000121CA File Offset: 0x000103CA
		public static bool CanGrowModPalmTree(int type)
		{
			return TileLoader.palmTrees.ContainsKey(type);
		}

		// Token: 0x060018B4 RID: 6324 RVA: 0x000121D7 File Offset: 0x000103D7
		public static void PalmTreeDust(Tile tile, ref int dust)
		{
			if (tile.active() && TileLoader.palmTrees.ContainsKey((int)tile.type))
			{
				dust = TileLoader.palmTrees[(int)tile.type].CreateDust();
			}
		}

		// Token: 0x060018B5 RID: 6325 RVA: 0x0001220A File Offset: 0x0001040A
		public static void PalmTreeGrowthFXGore(int type, ref int gore)
		{
			if (TileLoader.palmTrees.ContainsKey(type))
			{
				gore = TileLoader.palmTrees[type].GrowthFXGore();
			}
		}

		// Token: 0x060018B6 RID: 6326 RVA: 0x0001222B File Offset: 0x0001042B
		public static void DropPalmTreeWood(int type, ref int wood)
		{
			if (TileLoader.palmTrees.ContainsKey(type))
			{
				wood = TileLoader.palmTrees[type].DropWood();
			}
		}

		// Token: 0x060018B7 RID: 6327 RVA: 0x0001224C File Offset: 0x0001044C
		public static Texture2D GetPalmTreeTexture(Tile tile)
		{
			if (!tile.active() || !TileLoader.palmTrees.ContainsKey((int)tile.type))
			{
				return null;
			}
			return TileLoader.palmTrees[(int)tile.type].GetTexture();
		}

		// Token: 0x060018B8 RID: 6328 RVA: 0x0001227F File Offset: 0x0001047F
		public static Texture2D GetPalmTreeTopTextures(int type)
		{
			if (!TileLoader.palmTrees.ContainsKey(type))
			{
				return null;
			}
			return TileLoader.palmTrees[type].GetTopTextures();
		}

		// Token: 0x060018B9 RID: 6329 RVA: 0x000122A0 File Offset: 0x000104A0
		public static bool CanGrowModCactus(int type)
		{
			return TileLoader.cacti.ContainsKey(type);
		}

		// Token: 0x060018BA RID: 6330 RVA: 0x000122AD File Offset: 0x000104AD
		public static Texture2D GetCactusTexture(int type)
		{
			if (!TileLoader.cacti.ContainsKey(type))
			{
				return null;
			}
			return TileLoader.cacti[type].GetTexture();
		}

		// Token: 0x060018BB RID: 6331 RVA: 0x00421344 File Offset: 0x0041F544
		public static void PlaceInWorld(int i, int j, Item item)
		{
			int createTile = item.createTile;
			if (createTile < 0)
			{
				return;
			}
			foreach (Action<int, int, Item> action in TileLoader.HookPlaceInWorld)
			{
				action(i, j, item);
			}
			ModTile tile = TileLoader.GetTile(createTile);
			if (tile == null)
			{
				return;
			}
			tile.PlaceInWorld(i, j, item);
		}

		// Token: 0x040016B3 RID: 5811
		private static int nextTile = 470;

		// Token: 0x040016B4 RID: 5812
		internal static readonly IList<ModTile> tiles = new List<ModTile>();

		// Token: 0x040016B5 RID: 5813
		internal static readonly IList<GlobalTile> globalTiles = new List<GlobalTile>();

		// Token: 0x040016B6 RID: 5814
		internal static readonly IDictionary<int, ModTree> trees = new Dictionary<int, ModTree>();

		// Token: 0x040016B7 RID: 5815
		internal static readonly IDictionary<int, ModPalmTree> palmTrees = new Dictionary<int, ModPalmTree>();

		// Token: 0x040016B8 RID: 5816
		internal static readonly IDictionary<int, ModCactus> cacti = new Dictionary<int, ModCactus>();

		// Token: 0x040016B9 RID: 5817
		private static bool loaded = false;

		// Token: 0x040016BA RID: 5818
		private static int vanillaChairCount = TileID.Sets.RoomNeeds.CountsAsChair.Length;

		// Token: 0x040016BB RID: 5819
		private static int vanillaTableCount = TileID.Sets.RoomNeeds.CountsAsTable.Length;

		// Token: 0x040016BC RID: 5820
		private static int vanillaTorchCount = TileID.Sets.RoomNeeds.CountsAsTorch.Length;

		// Token: 0x040016BD RID: 5821
		private static int vanillaDoorCount = TileID.Sets.RoomNeeds.CountsAsDoor.Length;

		// Token: 0x040016BE RID: 5822
		private static Func<int, int, int, bool>[] HookKillSound;

		// Token: 0x040016BF RID: 5823
		private static TileLoader.DelegateNumDust[] HookNumDust;

		// Token: 0x040016C0 RID: 5824
		private static TileLoader.DelegateCreateDust[] HookCreateDust;

		// Token: 0x040016C1 RID: 5825
		private static TileLoader.DelegateDropCritterChance[] HookDropCritterChance;

		// Token: 0x040016C2 RID: 5826
		private static Func<int, int, int, bool>[] HookDrop;

		// Token: 0x040016C3 RID: 5827
		private static TileLoader.DelegateCanKillTile[] HookCanKillTile;

		// Token: 0x040016C4 RID: 5828
		private static TileLoader.DelegateKillTile[] HookKillTile;

		// Token: 0x040016C5 RID: 5829
		private static Func<int, int, int, bool>[] HookCanExplode;

		// Token: 0x040016C6 RID: 5830
		private static Action<int, int, int, bool>[] HookNearbyEffects;

		// Token: 0x040016C7 RID: 5831
		private static TileLoader.DelegateModifyLight[] HookModifyLight;

		// Token: 0x040016C8 RID: 5832
		private static Func<int, int, int, Player, bool>[] HookDangersense;

		// Token: 0x040016C9 RID: 5833
		private static TileLoader.DelegateSetSpriteEffects[] HookSetSpriteEffects;

		// Token: 0x040016CA RID: 5834
		private static Action[] HookAnimateTile;

		// Token: 0x040016CB RID: 5835
		private static Func<int, int, int, SpriteBatch, bool>[] HookPreDraw;

		// Token: 0x040016CC RID: 5836
		private static TileLoader.DelegateDrawEffects[] HookDrawEffects;

		// Token: 0x040016CD RID: 5837
		private static Action<int, int, int, SpriteBatch>[] HookPostDraw;

		// Token: 0x040016CE RID: 5838
		private static Action<int, int, int, SpriteBatch>[] HookSpecialDraw;

		// Token: 0x040016CF RID: 5839
		private static Action<int, int, int>[] HookRandomUpdate;

		// Token: 0x040016D0 RID: 5840
		private static TileLoader.DelegateTileFrame[] HookTileFrame;

		// Token: 0x040016D1 RID: 5841
		private static Func<int, int, int, bool>[] HookCanPlace;

		// Token: 0x040016D2 RID: 5842
		private static Func<int, int[]>[] HookAdjTiles;

		// Token: 0x040016D3 RID: 5843
		private static Action<int, int, int>[] HookRightClick;

		// Token: 0x040016D4 RID: 5844
		private static Action<int, int, int>[] HookMouseOver;

		// Token: 0x040016D5 RID: 5845
		private static Action<int, int, int>[] HookMouseOverFar;

		// Token: 0x040016D6 RID: 5846
		private static Func<int, int, int, Item, bool>[] HookAutoSelect;

		// Token: 0x040016D7 RID: 5847
		private static Func<int, int, int, bool>[] HookPreHitWire;

		// Token: 0x040016D8 RID: 5848
		private static Action<int, int, int>[] HookHitWire;

		// Token: 0x040016D9 RID: 5849
		private static Func<int, int, int, bool>[] HookSlope;

		// Token: 0x040016DA RID: 5850
		private static Action<int, Player>[] HookFloorVisuals;

		// Token: 0x040016DB RID: 5851
		private static TileLoader.DelegateChangeWaterfallStyle[] HookChangeWaterfallStyle;

		// Token: 0x040016DC RID: 5852
		private static TileLoader.DelegateSaplingGrowthType[] HookSaplingGrowthType;

		// Token: 0x040016DD RID: 5853
		private static Action<int, int, Item>[] HookPlaceInWorld;

		// Token: 0x02000247 RID: 583
		// (Invoke) Token: 0x060018BE RID: 6334
		private delegate void DelegateNumDust(int i, int j, int type, bool fail, ref int num);

		// Token: 0x02000248 RID: 584
		// (Invoke) Token: 0x060018C2 RID: 6338
		private delegate bool DelegateCreateDust(int i, int j, int type, ref int dustType);

		// Token: 0x02000249 RID: 585
		// (Invoke) Token: 0x060018C6 RID: 6342
		private delegate void DelegateDropCritterChance(int i, int j, int type, ref int wormChance, ref int grassHopperChance, ref int jungleGrubChance);

		// Token: 0x0200024A RID: 586
		// (Invoke) Token: 0x060018CA RID: 6346
		private delegate bool DelegateCanKillTile(int i, int j, int type, ref bool blockDamaged);

		// Token: 0x0200024B RID: 587
		// (Invoke) Token: 0x060018CE RID: 6350
		private delegate void DelegateKillTile(int i, int j, int type, ref bool fail, ref bool effectOnly, ref bool noItem);

		// Token: 0x0200024C RID: 588
		// (Invoke) Token: 0x060018D2 RID: 6354
		private delegate void DelegateModifyLight(int i, int j, int type, ref float r, ref float g, ref float b);

		// Token: 0x0200024D RID: 589
		// (Invoke) Token: 0x060018D6 RID: 6358
		private delegate void DelegateSetSpriteEffects(int i, int j, int type, ref SpriteEffects spriteEffects);

		// Token: 0x0200024E RID: 590
		// (Invoke) Token: 0x060018DA RID: 6362
		private delegate void DelegateDrawEffects(int i, int j, int type, SpriteBatch spriteBatch, ref Color drawColor, ref int nextSpecialDrawIndex);

		// Token: 0x0200024F RID: 591
		// (Invoke) Token: 0x060018DE RID: 6366
		private delegate bool DelegateTileFrame(int i, int j, int type, ref bool resetFrame, ref bool noBreak);

		// Token: 0x02000250 RID: 592
		// (Invoke) Token: 0x060018E2 RID: 6370
		private delegate void DelegateChangeWaterfallStyle(int type, ref int style);

		// Token: 0x02000251 RID: 593
		// (Invoke) Token: 0x060018E6 RID: 6374
		private delegate int DelegateSaplingGrowthType(int type, ref int style);
	}
}
